<?php echo $this->element('body_help');?>
<?php echo $this->element('breadcrumb');?>
<div class="wrap">
<div id="icon-users" class="icon32"><br></div>
<h2>
	<?php 
		if(isset($schedule_view)) 
			echo 'Lịch thực hiện: '.$schedule_view[0]['Schedule']['name'];
		else 
			echo 'Danh sách lịch thực hiện';
		?>
	<a class="button add-new-h2" href="<?php echo $this->webroot;?>schedule_registries/add/<?php if(isset($schedule_view)) echo $schedule_view[0]['Schedule']['id'];?>"><?php __('Thêm mới lịch');?></a>
</h2>
<?php echo $this->Session->flash();?>
<br/>

<form action="" method="get">
<div class="tablenav top">
	<div class="alignleft actions">
	<?php 
		$set_select ='';
		if(isset($select_schedule_id)){
			$set_select = $select_schedule_id;
		}
		echo $this->Form->input('search_schedule',array('label'=>'','options'=>$schedule,'value'=>$set_select,'onchange'=>'select_change(this.value);'));?>
	<script>
		function select_change(id) {
			
			window.location="<?php echo $this->webroot;?>schedule_registries/index/"+id;
		}
	</script>
	</div>
<br class="clear">
</div>

<table class="wp-list-table widefat fixed users" cellspacing="0">
	<thead>
		<tr>
			<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox"></th>
			<th scope="col" id="name" class="manage-column column-name sortable desc" style="">
				<span><?php echo $this->Paginator->sort('Lịch thực hiện','schedule_type_id');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Ngày bắt đầu','start_time');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Ngày kết thúc','end_time');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Luận văn năm','schedule_type_id');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Trạng thái','status');?></span></th>
			
		</tr>
	</thead>

	<tfoot>
		<tr>
		<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox"></th>
			<th scope="col" id="name" class="manage-column column-name sortable desc" style="">
				<span><?php echo $this->Paginator->sort('Lịch thực hiện','schedule_type_id');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Ngày bắt đầu','start_time');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Ngày kết thúc','end_time');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Luận văn năm','schedule_type_id');?></span></th>
			<th style="" class="manage-column column-date sortable asc" id="date" scope="col">
				<span><?php echo $this->Paginator->sort('Trạng thái','status');?></span></th>
		</tr>
	</tfoot>

	<tbody id="the-list" class="list:user">
		
		<?php
			$get_link ='';
			if(isset($schedule_view[0]['Schedule']['id']))
				$get_link = $schedule_view[0]['Schedule']['id'];
			if(count($scheduleRegistries) >0){
				$i = 0;
				foreach ($scheduleRegistries as $scheduleRegistry):
					$class = null;
					if ($i++ % 2 == 0) {
						$class = ' class="alternate"';
					}
					$id= $scheduleRegistry['ScheduleRegistry']['id'];
					
				?>
				<tr <?php echo $class;?>>
					<th scope="row" class="check-column"><input name="gourps_<?php echo $id;?>" id="gourps_<?php echo $id;?>" class="contributor" value="<?php echo $id;?>" type="checkbox"></th>
					<td class="username column-username">
						<img id="group_icon" alt="" src="<?php echo $this->webroot;?>img/project_categories.png" class="avatar avatar-32 grav-hashed grav-hijack" height="32" width="32">
						<strong>
						<?php echo $this->Html->link($scheduleRegistry['ScheduleType']['name'], array('controller' => 'schedule_types', 'action' => 'view', $scheduleRegistry['ScheduleType']['id'])); ?>
						&nbsp;</strong><br>
						<div class="row-actions">
							<span class="remove">
								<?php echo $this->Html->link(__('Xem', true), array('action' => 'view', $scheduleRegistry['ScheduleRegistry']['id'])); ?>
							</span>&nbsp;|&nbsp;
							<span class="remove">
								<?php echo $this->Html->link(__('Sửa', true), array('action' => 'edit', $scheduleRegistry['ScheduleRegistry']['id'])); ?>
							</span>|&nbsp;
							<span class="remove">
								<?php echo $this->Html->link(__('Xóa', true), array('action' => 'delete', $scheduleRegistry['ScheduleRegistry']['id']), null, sprintf(__('Có muốn xóa # %s?', true), $scheduleRegistry['ScheduleRegistry']['id'])); ?>
							</span>
						</div>
					</td>
					<td class="date column-date">
						<abbr title="<?php echo date("d-m-Y H:i:s",strtotime($scheduleRegistry['ScheduleRegistry']['start_time'])); ?>"><?php echo date("d-m-Y H:i:s",strtotime($scheduleRegistry['ScheduleRegistry']['start_time'])); ?>&nbsp;</abbr>
					</td>
					<td class="date column-date">
						<abbr title="<?php echo date("d-m-Y H:i:s",strtotime($scheduleRegistry['ScheduleRegistry']['end_time'])); ?>"><?php echo date("d-m-Y H:i:s",strtotime($scheduleRegistry['ScheduleRegistry']['end_time'])); ?>&nbsp;</abbr>
					</td>
					<td><?php echo $this->Html->link($scheduleRegistry['Schedule']['name'], array('controller' => 'schedules', 'action' => 'view', $scheduleRegistry['Schedule']['id'])); ?>&nbsp;</td>
					<td>
						<div class="img_set_active">
							<?php 
							$link_img = '<img src="'.$this->webroot.'img/';
							if($scheduleRegistry['ScheduleRegistry']['status'] == '1'){;	?>	
								<a title='Bạn muốn tắt trạng thái này' href="<?php echo $this->webroot.'schedule_registries/active_status_off/'.$scheduleRegistry['ScheduleRegistry']['id']?>/get_link:<?php echo $get_link;?>">
									<img width="20" height="20" src="/project/img/set_active_on.png" alt="">
								</a>
							<?php }else{;?>
							<a title='Năm đang thực thi' href="<?php echo $this->webroot.'schedule_registries/set_active/'.$scheduleRegistry['ScheduleRegistry']['id']?>/status_schelude_type:<?php echo $scheduleRegistry['ScheduleRegistry']['schedule_type_id'] ;?>/get_link:<?php echo $get_link;?>">
								<img width="20" height="20" src="/project/img/set_active_off.png" alt="">
							</a>
							<?php };?>&nbsp;
						</div>
					</td>
				

				
				</tr>
			<?php endforeach; 
			}else{
				echo '<th colspan="6">Chưa có dữ liệu</th>';
			};?>	
	</tbody>
</table>
<div class="tablenav bottom">
	<div class="tablenav-pages">
	<span class="displaying-num"><?php
	echo $this->Paginator->counter(array(
	'format' => __('Trang %page% của %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
	));
	?></span>
	<a href="#" title="Go to the first page" class="first-page"><?php echo $this->Paginator->prev(__('<<', true), array(), null, array('class'=>'disabled'));?></a>
	<span class="paging-input">| 	<?php echo $this->Paginator->numbers();?>
 |</span></span>
	<a href="#" title="Go to the last page" class="last-page"><?php echo $this->Paginator->next(__('>>', true), array(), null, array('class' => 'disabled'));?></a>
	</div>
</div>
</form>

<div class="actions">
	<h3><?php __('Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__('New Schedule Registry', true), array('action' => 'add')); ?></li>
		<li><?php echo $this->Html->link(__('List Schedules', true), array('controller' => 'schedules', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Schedule', true), array('controller' => 'schedules', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Schedule Types', true), array('controller' => 'schedule_types', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Schedule Type', true), array('controller' => 'schedule_types', 'action' => 'add')); ?> </li>
	</ul>
</div>
<br class="clear">
<div class="clear"></div>
</div><!-- wrap -->